/////////////////////////////////////////////////////////////////////////////
// Name:        Axis_Diag.cpp
// Purpose:     Dialog for Axis
// Author:      Matthew Gong
// Created:     05/08/2005
// Copyright:   (c) Matthew Gong
// Licence:     GPL licence
/////////////////////////////////////////////////////////////////////////////

#ifdef __GNUG__
// #pragma implementation
#endif

// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
#pragma hdrstop
#endif

#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif

// -*- C++ -*- generated by wxGlade 0.3.5.1 on Sun May  8 20:23:02 2005

#include "Axis_Diag.h"
#include "TreeItem.h"

AxisDialog::AxisDialog(wxWindow* parent, int id, const wxString& title, const wxPoint& pos, const wxSize& size, long style):
    wxDialog(parent, id, title, pos, size, style)
{
    // begin wxGlade: AxisDialog::AxisDialog
    label_name = new wxStaticText(this, -1, _("Name:"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
    const wxString combo_box_name_choices[] = {
        wxT("DRAG"),
        wxT("SIDE"),
        wxT("LIFT"),
        wxT("ROLL"),
        wxT("PITCH"),
        wxT("YAW"),
        wxT("FORWARD"),
        wxT("RIGHT"),
        wxT("DOWN"),
    };
    combo_box_name = new wxComboBox(this, -1, wxT(""), wxDefaultPosition, wxDefaultSize, 9, combo_box_name_choices, wxCB_DROPDOWN|wxCB_READONLY);
    label_unit = new wxStaticText(this, -1, _("Unit:"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT);
    const wxString combo_box_unit_choices[] = {
        wxT("LBS"),
        wxT("N"),
        wxT("LBS*FT"),
        wxT("N*M")
    };
    combo_box_unit = new wxComboBox(this, -1, wxT(""), wxDefaultPosition, wxDefaultSize, 4, combo_box_unit_choices, wxCB_DROPDOWN|wxCB_READONLY);
    button_ok = new wxButton(this, wxID_OK, _("OK"));
    button_cancel = new wxButton(this, wxID_CANCEL, _("Cancel"));

    set_properties();
    do_layout();
    // end wxGlade
}


void AxisDialog::set_properties()
{
    // begin wxGlade: AxisDialog::set_properties
    label_name->SetMinSize(wxSize(60, -1));
    combo_box_name->SetSelection(0);
    label_unit->SetMinSize(wxSize(60, -1));
    combo_box_unit->SetSelection(0);
    // end wxGlade
}


void AxisDialog::do_layout()
{
    // begin wxGlade: AxisDialog::do_layout
    wxBoxSizer* sizer_1 = new wxBoxSizer(wxVERTICAL);
    wxBoxSizer* sizer_8 = new wxBoxSizer(wxHORIZONTAL);
    wxBoxSizer* sizer_7 = new wxBoxSizer(wxHORIZONTAL);
    wxBoxSizer* sizer_6 = new wxBoxSizer(wxHORIZONTAL);
    sizer_6->Add(label_name, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
    sizer_6->Add(combo_box_name, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
    sizer_1->Add(sizer_6, 1, wxEXPAND, 0);
    sizer_7->Add(label_unit, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
    sizer_7->Add(combo_box_unit, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
    sizer_1->Add(sizer_7, 1, wxEXPAND, 0);
    sizer_8->Add(button_ok, 1, wxALL, 10);
    sizer_8->Add(button_cancel, 1, wxALL, 10);
    sizer_1->Add(sizer_8, 1, wxEXPAND, 0);
    SetAutoLayout(true);
    SetSizer(sizer_1);
    sizer_1->Fit(this);
    sizer_1->SetSizeHints(this);
    Layout();
    // end wxGlade
}


void AxisDialog::Load(const TreeItemData_axis * data)
{
  combo_box_name->SetValue(data->name);
  combo_box_unit->SetValue(data->unit);
}
    
void AxisDialog::Save(TreeItemData_axis * data)
{
  data->name = combo_box_name->GetValue();
  data->unit = combo_box_unit->GetValue();
  data->tree->SetItemText(data->GetId(), data->name + wxT("(") + data->unit + wxT(")"));
}
